package com.woniu01;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Arrays;

public class Test {
    public static void main(String[] args) throws IOException {

        FileInputStream fis = new FileInputStream("a.txt");
        byte[] b = new byte[3];
        int sum;
        while ((sum = fis.read(b)) != -1) {
            System.out.println(new String(b,0,sum));
        }
        fis.close();
    }

    private static void test04() throws IOException {
        FileInputStream fis = new FileInputStream("a.txt");
        int data;
        while ((data=fis.read()) != -1) {
            System.out.println((char) data);
        }
    }

    private static void test03() throws IOException {
        FileOutputStream fos = new FileOutputStream("a.txt");
        fos.write("abcd".getBytes());
        fos.close();
    }

    private static void test02() throws IOException {
        FileInputStream fis = new FileInputStream("a.txt");
        System.out.println(fis.read());
    }

    private static void test01() throws IOException {
        FileOutputStream fos = new FileOutputStream("a.txt");
        fos.write(97);
        fos.close();
    }
}
